package com.kaishengit.service;

import org.springframework.transaction.annotation.Transactional;

import com.kaishengit.dao.UserDao;
import com.kaishengit.pojo.User;

@Transactional
public class UserService {

	private UserDao userDao;
	
	public void save(User user) {
		userDao.save(user);
	}
	
	public User login(User user) {
		
		User u =  userDao.findByUnique("username", user.getUsername());
		
		if(u != null && u.getPassword().equals(user.getPassword())) {
			return u;
		}else {
			return  null;
		}
	}

	
	//set get
	
	public void setUserDao(UserDao  userDao) {
		this.userDao =  userDao;
	}

	public User findById(String userid) {
		return userDao.findByUnique("id", userid);
	}

	

	

	
	
	
}
